﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Utility.TaskSystem
{
	public class TaskManager : SingletonBehaviour<TaskManager>
	{
		TaskGroup group = new TaskGroup ();

		public static Task Add (Task task)
		{
			return Inst.group.Add (task);
		}

		public static Task AddNew (IEnumerator<Task> co_func)
		{
			return Inst.group.Add (co_func);
		}

		public static bool Remove (Task task)
		{
			return Inst.group.Remove (task);
		}


		#region unity
		private void Start ()
		{
			StartCoroutine (CO_Update ());
		}

		IEnumerator CO_Update ()
		{
			while (true)
			{
				group.Update ();
				yield return null;
			}
		}
		#endregion
	}
}